String.prototype.occurrenceOf = function(expression)
{
	if(typeof expression == 'string') {
		return {
			index:  this.indexOf(expression),
			length: expression.length
		};
	}
		
	if(result = expression.exec(this)) return {
		index:  result.index,
		length: result[0].length
	};
	else return {
		index:  -1,
		length: -1
	};
}

String.prototype.lastOccurrenceOf = function(expression)
{
	if(typeof expression == 'string') return {
		index:  this.lastIndexOf(expression),
		length: expression.length
	};
	

	if(expression.exec) {
		var subject = this;
		var index = 0;
		var result = null;
		var lastLength = 1;
	
		while(result = expression.exec(subject)) {		
			lastLength = result[0].length;
			index += result.index + lastLength;
			subject = this.substr(index);
		}
			
		return {
			index:  index - lastLength ,
			length: lastLength
		};
	} else return {
		index: -1,
		length: -1
	};
}